import { Form, Input, Select, DatePicker, Button, message } from 'antd';
import React from 'react';
import { useNavigate } from 'react-router-dom';
import * as service from '../../../api/zzachieve'
import * as service1 from '../../../api/zzachieve1'
import './AchieFirstAdd.scss'
interface Props { }
function AchieFirstAdd(props: Props) {

    const { RangePicker } = DatePicker;

    const [messageApi, contextHolder] = message.useMessage();

    const { Option } = Select;

    const navigate = useNavigate()

    const onFinish = (values: any) => {
       
        console.log('Success:', values);
        // service.people_add(values).then(res => {
        service1.people_add(values).then(res => {
            console.log(res)
            if (res.status == 201) {
                messageApi.open({
                    type: 'success',
                    content: '添加成功',
                });
                navigate('/index/achievements/achieFirst')
            }
        })
    };

    const onFinishFailed = (errorInfo: any) => {
        console.log('Failed:', errorInfo);
    };


    return (
        <div className='add'>
            <div className='top'>基础信息</div>
            <Form
                labelCol={{ span: 4 }}
                wrapperCol={{ span: 14 }}
                layout="horizontal"
                style={{ maxWidth: 600 }}
                onFinish={onFinish}
                onFinishFailed={onFinishFailed}
            >
                <Form.Item label="考核组名称" name='name' rules={[{ required: true }]}>
                    <Input />
                </Form.Item>
                <Form.Item name="type" label="考核周期" rules={[{ required: true }]}>
                    <Select
                        placeholder=""
                        allowClear
                    >
                        <Option value="月度">月度</Option>
                        <Option value="季度">季度</Option>
                        <Option value="半年度">半年度</Option>
                        <Option value="年度">年度</Option>
                        <Option value="其他">其他</Option>
                    </Select>
                </Form.Item>
                <Form.Item label="考核周期" name='cycle'>
                    <RangePicker picker="month" />
                </Form.Item>
                <Form.Item name="ranges" label="考核范围" >
                    <Select
                        placeholder=""
                        allowClear
                    >
                        <Option value="销售一组,销售二组">销售一组,销售二组</Option>
                        <Option value="销售三组,销售四组">销售三组,销售四组</Option>
                        <Option value="销售五组,销售六组">销售五组,销售六组</Option>
                    </Select>
                </Form.Item>
                <Form.Item label="考核说明" name='state'>
                    <Input />
                </Form.Item>
                <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                    <Button type="primary" htmlType="submit">
                        保存
                    </Button>
                </Form.Item>
            </Form>
            {contextHolder}
        </div>

    );
}
export default AchieFirstAdd;